﻿using Firestarter.DB.Schema.BO;
using FireStarterModeller.Test;
using Habanero.Testability;

namespace Firestarter.DB.Schema.Test.BO.TestUtils
{
    // Provides a part of the TestUtilsBase class that creates sample DMLookupList objects.
    // If these methods create invalid data, then implement custom overrides in the
    // TestUtils class.

    public class TestUtilsDBTable
    {

        public static BOTestFactory<DBTable> GetTestFactory()
        {
            return BOTestFactoryRegistry.Instance.Resolve<DBTable>();
        }
        /// <summary>
        /// Creates a new saved DBTable with a random value assigned to every property
        /// </summary>
        public static DBTable CreateSavedDBTable()
        {
            DBTable dBTable = CreateUnsavedValidDBTable();
            dBTable.Save();
            return dBTable;
        }

        /// <summary>
        /// Creates a new unsaved DBTable with a random value assigned to every property
        /// </summary>
        public static DBTable CreateUnsavedValidDBTable()
        {
            DBTable dBTable = new DBTable();
            dBTable.DateCreated = TestUtilsShared.GetRandomDate();
            dBTable.Owner = TestUtilsShared.GetRandomString();
            dBTable.TableName = TestUtilsShared.GetRandomString(1, 255);
            dBTable.DatabaseID = TestUtilsDBDatabase.CreateSavedDBDatabase().DatabaseID;
            dBTable.TableType = TestUtilsShared.GetRandomString();
            dBTable.TableComment = TestUtilsShared.GetRandomString();
            dBTable.CreateTime = TestUtilsShared.GetRandomDate();
            dBTable.UpdateTime = TestUtilsShared.GetRandomDate();
            //			dBTable.PendingChangeType = null;
            dBTable.Approved = TestUtilsShared.GetRandomBoolean();
            return dBTable;
        }

        /// <summary>
        /// Creates a new unsaved DBTable where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static DBTable CreateUnsavedDefaultDBTable()
        {
            DBTable dBTable = new DBTable();
            return dBTable;
        }
    }
}